import { myAxios } from "./core"

//管理请求
export const http = {
    //登录
    login: promise => {
        return myAxios("POST", '/login', promise)
    },
    //用户列表
    users: promise => {
        return myAxios("GET", '/users', promise)
    },
    //添加用户
    addusers: promise => {
        return myAxios("POST", '/users', promise)
    },
    //修改用户信息
    xiugaiusers: promise => {
        return myAxios("PUT", `/users/${promise.id}`, promise)
    },
    //角色列表
    roles: promise => {
        return myAxios("GET", 'roles', promise)
    },
    //添加角色
    addroles: promise => {
        return myAxios("POST", 'roles', promise)
    },
    //删除角色
    deleteroles: promise => {
        return myAxios("DELETE", `roles/${promise.id}`, promise)
    },
    //编辑角色
    bianjiroles: promise => {
        return myAxios("PUT", `roles/${promise.id}`, promise)
    },
    //权限列表
    quanxian: promise => {
        return myAxios("GET", `rights/tree`, promise)
    },
    quanxianlist: promise => {
        return myAxios("GET", `/rights/list`, promise)
    },
    //删除权限
    delquanxian: promise => {
        return myAxios("DELETE", `roles/${promise.roleId}/rights/${promise.rightId}`, promise)
    },
    //商品列表
    goods: promise => {
        return myAxios("GET", `/goods`, promise)
    },
    //删除商品
    delgoods: promise => {
        return myAxios("DELETE", `/goods/${promise.id}`, promise)
    },
    //图表数据
    getreports: promise => {
        return myAxios("GET", 'reports/type/1', promise)
    },
    // 商品分类列表
    categories: promise => {
        return myAxios("GET", 'categories', promise)
    },
    
}



